<?php

/**
 * @Project NUKEVIET 3.0
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
 * @Createdate 2-9-2010 14:43
 */

if(!defined('NV_IS_ALBUMS_ADMIN'))
{
	die('Stop!!!');
}

//////////////////////////////////////////////////
$page_title = $lang_module['setting'];
//////////////////////////////////////////////////////////////
$savesetting = $nv_Request->get_int( 'savesetting', 'post', 0 );
$error = "";
if ( $savesetting == 1 )
{
	$data=array();
    $data['viewcat'] = $nv_Request->get_string( 'viewcat', 'post','' );
    $data['width'] = $nv_Request->get_int( 'width', 'post', 0 );
    $data['height'] = $nv_Request->get_int( 'height', 'post', 0 );
    $data['widthc'] = $nv_Request->get_int( 'widthc', 'post', 0 );
    $data['heightc'] = $nv_Request->get_int( 'heightc', 'post', 0 );
    $data['per_page'] = $nv_Request->get_int( 'per_page', 'post', 0 );
    $data['main_page'] = $nv_Request->get_int( 'main_page', 'post', 0 );
    $data['admin_page'] = $nv_Request->get_int( 'admin_page', 'post', 0 );
    if ( $error == '' )
    {
        foreach ( $data as $config_name => $config_value )
        {
            $db->sql_query( "REPLACE INTO `" . NV_CONFIG_GLOBALTABLE . "` (`lang`, `module`, `config_name`, `config_value`) VALUES('" . NV_LANG_DATA . "', " . $db->dbescape( $module_name ) . ", " . $db->dbescape( $config_name ) . ", " . $db->dbescape( $config_value ) . ")" );
        }
        
        nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['setting'], "setting", $admin_info['userid'] );
        nv_del_moduleCache( 'settings' );
        nv_del_moduleCache( $module_name );
        
        Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . '=setting' );
        die();
    }
}

$xtpl = new XTemplate( "setting.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
$xtpl->assign( 'LANG', $lang_module );
$data['width'] = $module_config[$module_name]['width'];
$data['height'] = $module_config[$module_name]['height'];
$data['widthc'] = $module_config[$module_name]['widthc'];
$data['heightc'] = $module_config[$module_name]['heightc'];
$data['per_page'] = $module_config[$module_name]['per_page'];
$data['main_page'] = $module_config[$module_name]['main_page'];
$data['admin_page'] = $module_config[$module_name]['admin_page'];
$data['viewcat'] = $module_config[$module_name]['viewcat'];
$xtpl->assign( 'DATA', $data );
$xtpl->assign( 'MODULE_NAME', $module_name );
$check_view = array( 
    "normal" => "", "slide" => "", "slide_pro" => "" 
);
$check_view[$data['viewcat']] = "selected=\"selected\"";
foreach ( $check_view as $type_view => $select )
{
    $xtpl->assign( 'type_view', $type_view );
    $xtpl->assign( 'view_selected', $select );
    $xtpl->assign( 'name_view', $lang_module[$type_view] );
    $xtpl->parse( 'main.home_view_loop' );
}
if ( ! empty( $error ) )
{
    $xtpl->assign( 'error', $error );
    $xtpl->parse( 'main.error' );
}


$xtpl->parse( 'main' );

$contents .= $xtpl->text( 'main' );
include ( NV_ROOTDIR . "/includes/header.php" );
echo nv_admin_theme( $contents );
include ( NV_ROOTDIR . "/includes/footer.php" );
?>